<?php

function db_inserir_newsletter($dados){
    
    $result = db_select('newsletters', 'email')
    ->fields('email')
    ->condition('email', $dados["email"],'=')
    ->execute()
    ->fetchAssoc();
    
    if ($result != false) {
        throw new Exception('E-MAIL J&aacute; cadastrado...');
    }
    
    $objQuery = db_insert('newsletters')->fields($dados)->execute();
    
    return $objQuery;
    
}

?>